﻿using System;

/*Write a program that finds in given array of integers a sequence of given sum S (if present). Example:
 * {4, 3, 1, 4, 2, 5, 8}, S=11  {4, 2, 5}*/

class BiggestSequenceSum
{
    static void Main()
        {
            int[] array = new int[] { 4, 3, 1, 4, 2, 2, 1, 8 };

            int targetSum = 11;

            for (int i = 0; i < array.Length; i++)
            {
                int curSum = 0;
                for (int j = i; j < array.Length; j++)
                {
                    curSum += array[j];

                    if (curSum == targetSum)
                    {
                        Console.WriteLine("The sequence has sum of {0} from position {1} and sequence of {2} elements", targetSum, i, j-i+1);
                    }
                }

            }
        }
}
            
            
                   